**************************************************************************************************************************************************************** 
* Author: Cecilia Hyunjung Mo
* Date: June 5, 2018
* Replication File for Table E.9 - "When Do the Advantaged See the Disadvantages of Others? \\ A Quasi-Experimental Study of National Service"
**************************************************************************************************************************************************************** 

* AmericasBarometer (2010): System Support (Rows 1-3)
clear all
use "GrandMerge14 25p draft0912.dta"

foreach i of varlist b2 b3 {
  replace `i' = (`i'-1)/6
 }
 
 *Haiti= pais 22
 *US= pais 40
 
 tab pais
 tab pais, nolab
 
 sum b2 if pais ==22 & year==2010
 sum b2 if pais ==40 & year==2010
 
 sum b3 if pais ==22 & year==2010
 sum b3 if pais ==40 & year==2010
 
 egen system_index = rowmean(b2 b3) 
 sum system_index if pais ==22 & year==2010
 sum system_index if pais ==40 & year==2010
 
 
* World Values Survey (1995-1998) - Wave 6: Class-Based Injustice (Rows 4-7)
clear all
use "WV6_Data_stata_v_2015_04_18.dta", clear

* Rescale to match scale in TFA data
tab V96
gen civic31b_wvs = V96 if V96>0
tab civic31b_wvs
 replace civic31b_wvs = (10-civic31b_wvs)/9

tab V98
gen civic31c_wvs = V98 if V98>0
tab civic31c_wvs
 replace civic31c_wvs = (10-civic31c_wvs)/9


tab V100
gen civic31d_wvs = V100 if V100>0
tab civic31d_wvs
 replace civic31d_wvs = (civic31d_wvs-1)/9
 
egen lib_index = rowmean(civic31b_wvs civic31c_wvs civic31d_wvs)
  
sum civic31b_wvs if V2 == 276
sum civic31b_wvs if V2 == 840
 
sum civic31c_wvs if V2 == 276
sum civic31c_wvs if V2 == 840
 
sum civic31d_wvs if V2 == 276
sum civic31d_wvs if V2 == 840

sum lib_index if V2==276
sum lib_index if V2==840



* ANES 2008 Data: Racial Injustice (Rows 8-12)
clear all
use "anes_timeseries.dta", clear
*VCF9042 = resent1
*VCF9040 = resent2
*VCF9041 = resent3
*VCF9039 = resent4

* Rescale to match scale in TFA data
gen resent1 = (5-VCF9042)/4 if VCF9042<6
tab resent1
gen resent2 = (5-VCF9040)/4 if VCF9040<6
tab resent2
gen resent3 = (5-VCF9041)/4 if VCF9041<6
tab resent3
gen resent4 = (5-VCF9039)/4 if VCF9039<6
tab resent4

* Inverting some measures to create an index where higher values represent more racial resentment
*gen resent_index = (resent1+resent2+resent3+resent4)/4
*sum resent_index
gen resent1_index = (VCF9042-1)/4 if VCF9042<6
tab resent1_index
gen resent2_index = (5-VCF9040)/4 if VCF9040<6
tab resent2_index
gen resent3_index = (5-VCF9041)/4 if VCF9041<6
tab resent3_index
gen resent4_index = (VCF9039-1)/4 if VCF9039<6
tab resent4_index
egen resent_index2 = rowmean(resent1_index resent2_index resent3_index resent4_index)

* Whites
sum resent1 if VCF0106a==1 & survey_year==2008
sum resent2 if VCF0106a==1 & survey_year==2008
sum resent3 if VCF0106a==1 & survey_year==2008
sum resent4 if VCF0106a==1 & survey_year==2008
sum resent_index2 if VCF0106a==1 & survey_year==2008

* Blacks
sum resent1 if VCF0106a==2 & survey_year==2008
sum resent2 if VCF0106a==2 & survey_year==2008
sum resent3 if VCF0106a==2 & survey_year==2008
sum resent4 if VCF0106a==2 & survey_year==2008
sum resent_index2 if VCF0106a==2 & survey_year==2008

 
 
**** Project Implicit Data -- Racial Prejudice (Rows 13-14)
clear all
use "skintone_iat_pi.dta", clear

rename D_biep_LightSkin_Good_all iat_score
keep year iat_score religionid age sex ethnic raceomb ethnicityomb

gen White = 0 if raceomb~=. | ethnic~=. | raceomb~=-999
 replace White = 1 if raceomb==6 | ethnic==5
gen Black = 0 if raceomb~=. | ethnic~=. | raceomb~=-999
 replace Black = 1 if raceomb==5 | ethnic==3
gen Asian = 0 if raceomb~=. | ethnic~=. | raceomb~=-999
 replace Asian = 1 if raceomb==2 | raceomb==3 | ethnic==2
gen Hispanic = 0 if ethnicityomb~=. | ethnic~=. | ethnicityomb~=-999
 replace Hispanic = 1 if ethnicityomb==1 | ethnic==4
 
sum iat_score if White==1 & year==2015
sum iat_score if Black==1 & year==2015
sum iat_score if Hispanic ==1 & year ==2015
 



